<template>
  <div v-if="visible" class="dialog-wrapper">
    <div class="herin-dialog" :style="`width:${width}`">
      <div class="herin-dialog-header">
        <slot name="title">
          <span class="text">{{ title }}</span>
          <span class="close el-icon-close" @click="closeDialog" />
        </slot>
      </div>
      <div class="herin-dialog-body">
        <slot name="content" />
      </div>
      <div v-if="$slots.footer" class="herin-dialog-footer">
        <slot name="footer" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HerinDialog',
  props: {
    title: {
      type: String,
      default: () => '标题'
    },
    visible: {
      type: Boolean,
      default: () => true
    },
    width: {
      type: String,
      default: () => '31.25rem'
    }
  },
  data() {
    return {};
  },
  methods: {
    closeDialog() {
      this.$emit('update:visible', false);
    }
  }

};
</script>
<style scoped lang="scss">
.dialog-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);

  .herin-dialog {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 12.5rem;
    border-radius: .25rem;

    &-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0rem 1rem;
      height: 2.5rem;
      background-color: rgba(0, 0, 0, .6);

      .text {
        margin: 0rem 0.1875rem;
        flex: 1;
        display: inline-flex;
        align-items: center;
        font-size: 1rem;
        color: #fff;
        &::before {
          margin-right: 0.625rem;
          display: inline-block;
          width: 0.1875rem;
          height: 1rem;
          margin-top: 0.0625rem;
          content: '';
          background-color: #00FDFF;
        }
      }

      .close {
        width: 1.875rem;
        line-height: 3.75rem;
        font-size: 1rem;
        color: $cyan;
        text-align: right;
        cursor: pointer;
      }
    }

    &-body {
      color: #fff;
      flex: 1;
      margin-top: 0.625rem;
      background-color: rgba(0, 0, 0, .6);
    }

    &-body,
    &-footer {
      padding: 0.9375rem;
    }
  }
}
</style>
